﻿@model IEnumerable<CloudFranceTriple.WebRole.Models.TopicResult>
@{    
    if ((ViewBag.Title as string) == null & ViewBag.SiteMapPath1.ToString() != String.Empty)
    {
        ViewBag.Title = String.Format("{0} > {1}", ViewBag.SiteMapPath1.ToString(), ViewBag.SiteMapPath2.ToString());
    }

    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="content-padding">
    @if (ViewBag.SiteMapPath1 as string != String.Empty)
    {
        <h5>@Html.ActionLink(ViewBag.SiteMapPath1 as string, "Index", "Forum", new { area = "Forum" }, null) > @ViewBag.SiteMapPath2 (@Model.Count()) > @ViewBag.LocalizedUserRights</h5>
    }
    else
    {
        <h1>@ViewBag.Title (@Model.Count())</h1>
    }
    @Html.Action("ShowOnTopic", "Annonce", new { area = "Forum" })
    @Html.Partial("_TopicQueriesLinks")
    <section>
        @{if ((ViewBag.ShowCreate as Boolean?) ?? false)
          {
            <p>
                @Html.ActionLink(@CloudFranceTriple.WebRole.Properties.Resources.TopicCreateButton, "Create", "Topic", new { area = "Forum", id = ViewBag.Category_Id as int? }, null)
            </p>
          }
        }
        <table class="topiclist">
            <thead>
                <tr>
                    <th class="topiclistcol1 topiclistcenter">
                        @CloudFranceTriple.WebRole.Properties.Resources.TopicIsUnlocked
                    </th>
                    <th class="topiclistcol2">
                        @CloudFranceTriple.WebRole.Properties.Resources.TopicLabel
                    </th>
                    <th class="topiclistcol3">
                        @CloudFranceTriple.WebRole.Properties.Resources.TopicAutor
                    </th>
                    <th class="topiclistcol4">
                        @CloudFranceTriple.WebRole.Properties.Resources.TopicNumberHasBeenSeen
                    </th>
                    <th class="topiclistcol5">
                        @CloudFranceTriple.WebRole.Properties.Resources.TopicLastCreationDate
                    </th>
                    <th class="topiclistcol6"></th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td class="topiclistcol1 topiclistcenter">
                            @Html.DisplayFor(modelItem => item.IsUnlocked)
                        </td>
                        <td class="topiclistcol2">
                            @Html.ActionLink(HttpUtility.HtmlDecode(item.Label), "Index", "Post", new { id = item.Id, area = "forum" }, null)
                        </td>
                        <td class="topiclistcol3">
                            @Html.DisplayFor(modelItem => item.Author)
                        </td>
                        <td class="topiclistcol4">
                            @Html.DisplayFor(modelItem => item.NumberHasBeenSeen)
                        </td>
                        <td class="topiclistcol5">
                            @Html.DisplayFor(modelItem => item.LastPostDate)
                        </td>
                        <td class="topiclistcol6 topiclistcenter">
                            @{if (User.IsInRole("RoleAdminForum") || User.Identity.Name.ToLower() == item.Author.ToLower())
                              {
                                @Html.ActionLink(CloudFranceTriple.WebRole.Properties.Resources.ButtonEdit, "Edit", new { id = item.Id });
                              }
                            }
                            @{if (User.IsInRole("RoleAdminForum"))
                              {
                                @Html.ActionLink(CloudFranceTriple.WebRole.Properties.Resources.ButtonDelete, "Delete", new { id = item.Id });
                              }
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        @{if ((ViewBag.ShowCreate as Boolean?) ?? false)
          {
            <p>
                @Html.ActionLink(@CloudFranceTriple.WebRole.Properties.Resources.TopicCreateButton, "Create", "Topic", new { area = "Forum", id = ViewBag.Category_Id as int? }, null)
            </p>
          }
        }
    </section>
    @Html.Partial("_TopicQueriesLinks")
    @if (ViewBag.SiteMapPath1 as string != String.Empty)
    {
        <h5>@Html.ActionLink(ViewBag.SiteMapPath1 as string, "Index", "Forum", new { area = "Forum" }, null) > @ViewBag.SiteMapPath2 > @ViewBag.LocalizedUserRights</h5>
    }
</div>
